package com.water.mapper;

import com.water.entity.User;
import com.water.vo.UserUpVo;
import com.water.vo.UserVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @program: city_water
 * @description:
 * @author: lydms
 * @create: 2024-05-09 23:09
 **/

@Mapper
public interface UserMapper {

    /**
     * 查询用户跟据手机号
     * @param phone
     * @return
     */
    @Select("select * from users where phone=#{phone}")
    User selectByPhone(String phone);

    /**
     * 插入用户
     * @param user1
     */
    @Insert("insert into users(name, address, phone, type, password, create_time, update_time) " +
            "VALUES " +
            "(#{name},#{address},#{phone},#{type},#{password},#{createTime},#{updateTime})")
    void insert(User user1);


    /**
     * 跟据用户id查询
     * @param userId
     * @return
     */
    @Select("select * from users where user_id=#{userId}")
    User selectByUserId(Long userId);

    /**
     * 更新用户
     * @param userUpVo
     */
    @Insert("update users set name=#{name},address=#{address},phone=#{phone},type=#{type},update_time=#{updateTime} where user_id=#{userId}")
    void update(UserUpVo userUpVo);
}
